package com.hddf.project.auth.pojos;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

@Entity
@Table(name="authority")
public class Authority {
	public static final String mongodb_collection_name = "authority";
	   /*id int(11) not null auto_increment comment '自增id',
	   name varchar(32) not null  comment '权限名',
	   pid int(11) default null comment '父id',
	   url varchar(255) default null comment '权限对应的访问地址 , 分隔符',
	   isleaf tinyint  default 1 comment '是否是叶子节点,0否,1是',
	   sort tinyint not null default 1 comment '排序 1-127',
	   userid int(11) not null comment '修改人ID',
	   username varchar(32) not null comment '修改人用户名',
	   update_time datetime not null comment '修改时间',
	   state tinyint not null default 1 comment '状态(1:正常,0:删除)',*/
	
	private int id;
	private String name;
	private int pid; //暂时不使用
	private String url;
	private int isleaf; //暂时不是使用
	private int sort; 
	private int userid;
	private String username;
	private Date update_time;
	private int state;
	
	/**
	 * 将一个pojo对象转换为一个mongodb对象
	 * @return
	 */
	public DBObject toDbObject(){
        BasicDBObject entity = new BasicDBObject();
        entity.put("auth_id", id);
        entity.put("name", name);
        entity.put("pid", pid);
        entity.put("url",url);
        entity.put("isleaf",isleaf);
        entity.put("sort",sort);
        entity.put("state", state);
        return entity;
	}
	
	public Authority(){
		
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY )
	@Column(name="id" ,nullable=false,unique=true)
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name="name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name="pid")
	public int getPid() {
		return pid;
	}
	public void setPid(int pid) {
		this.pid = pid;
	}
	
	@Column(name="url")
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	
	@Column(name="isleaf")
	public int getIsleaf() {
		return isleaf;
	}
	public void setIsleaf(int isleaf) {
		this.isleaf = isleaf;
	}
	
	@Column(name="sort")
	public int getSort() {
		return sort;
	}
	public void setSort(int sort) {
		this.sort = sort;
	}
	
	@Column(name="userid")
	public int getUserid() {
		return userid;
	}
	public void setUserid(int userid) {
		this.userid = userid;
	}
	
	@Column(name="username")
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	
	@Column(name="update_time")
	public Date getUpdate_time() {
		return update_time;
	}
	public void setUpdate_time(Date update_time) {
		this.update_time = update_time;
	}
	
	@Column(name="state")
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
}
